package com.shoulder.log.enums;

import com.shoulder.log.printer.ConsoleLogPrinter;
import com.shoulder.log.printer.LogPrinter;
import com.shoulder.log.printer.LogstashLogPrinter;

public enum LogPrinterEnum {
    CONSOLE(LogTypeEnum.CONSOLE.getType(), new ConsoleLogPrinter()),
    LOGSTASH(LogTypeEnum.LOGSTASH.getType(), new LogstashLogPrinter());
    private String type;
    private LogPrinter printer;

    LogPrinterEnum(String type, LogPrinter printer) {
        this.printer = printer;
        this.type = type;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public LogPrinter getPrinter() {
        return printer;
    }

    public void setPrinter(LogPrinter printer) {
        this.printer = printer;
    }

    public static LogPrinter obtainPrinter(String type) {
        LogPrinterEnum[] values = LogPrinterEnum.values();
        for (LogPrinterEnum value : values) {
            if (value.getType().equals(type)) {
                return value.getPrinter();
            }
        }
        return new ConsoleLogPrinter();
    }
}
